class FamiliesController < ApplicationController
	load_and_authorize_resource :through => :account

  # GET /families/new
  # GET /families/new.xml
  def new
    #@family = Family.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @family }
    end
  end

  # GET /families/1/edit
  def edit
    #@family = Family.find(params[:id])
  end

  # POST /families
  # POST /families.xml
  def create
    #@family = Family.new(params[:family])
    @family.profile = current_user.profile

    respond_to do |format|
      if @family.save
        flash[:notice] = 'Family was successfully created.'
        format.html { redirect_to(account_path) }
        format.xml  { render :xml => @family, :status => :created, :location => @family }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @family.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /families/1
  # PUT /families/1.xml
  def update
    #@family = Family.find(params[:id])

    respond_to do |format|
      if @family.update_attributes(params[:family])
        flash[:notice] = 'Family was successfully updated.'
        format.html { redirect_to(account_path) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @family.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /families/1
  # DELETE /families/1.xml
  def destroy
    #@family = Family.find(params[:id])
    @family.destroy

    respond_to do |format|
      format.html { redirect_to(account_path) }
      format.xml  { head :ok }
    end
  end
end
